package in.muton.edushare.grading.panels;

import in.muton.edushare.academics.panels.EntityGradePanel;
import in.muton.edushare.grading.panels.studentGrades.StudentMainGradePanel;
import in.muton.edushare.pages.common.EdusharePanel;
import in.muton.edushare.pages.coursepages.CourseGrading;

import org.apache.wicket.markup.html.JavascriptPackageResource;
import org.apache.wicket.model.IModel;

import com.edushare.common.vo.CourseInstances;

public class CourseGradePanel extends EdusharePanel {
	private static final long serialVersionUID = 4233069833941880294L;

	public CourseGradePanel(String id, final CourseGrading gradePage,
			IModel<CourseInstances> cModel) {
		super(id, gradePage);
		add(JavascriptPackageResource.getHeaderContribution(CourseGradePanel.class, "courseGradeDisp.js"));
		add(new EntityGradePanel("gradeKeyPanel", gradePage, cModel.getObject()) {
			private static final long serialVersionUID = 6641676596094090548L;

			@Override
			public boolean isVisible() {
				return gradePage.getActivePanel() == CourseGrading.GRADE_KEY;
			}
		});
		NewGradeItemPanel ngip = new NewGradeItemPanel("newGradeItemPanel",
				gradePage, cModel.getObject()){
			private static final long serialVersionUID = 6641676596094090548L;

			@Override
			public boolean isVisible() {
				return gradePage.getActivePanel() == CourseGrading.NEW_GRADE_COMPONENT;
			}
		};
		add(ngip);
		StudentMainGradePanel smgp;
		add(smgp = new StudentMainGradePanel("studentMainGradePanel", gradePage, cModel){
			@Override
			public boolean isVisible(){
				return gradePage.getActivePanel() == CourseGrading.COURSE_GRADES;
			}
			private static final long serialVersionUID = -4283747894624469834L;
		});
		
		add(new GradeItemsList("gradeItemsList", gradePage, cModel, ngip, smgp) {
			private static final long serialVersionUID = 6641676596094090548L;

			@Override
			public boolean isVisible() {
				return gradePage.getActivePanel() == CourseGrading.GRADE_COMPONENTS;
			}
		});		
	}
}
